package edu.bw.config;

import org.springframework.context.annotation.*;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.sql.Connection;

@Configuration //代表这是一个Spring配置类,相当于将xml中配置转换成java类和注解的形式
@ComponentScan("edu.bw") //扫描包及子包下的注解, 相当于配置文件中 <context:component-scan base-package="edu.bw"/>
@PropertySource("classpath:db.properties")//加载properties配置文件, 相当于配置文件中的<context:property-placeholder location="classpath:db.properties"/>
@Import({DBConfig.class,TransactionConfig.class}) //导入DBConfig配置类和TransactionConfig配置类
@EnableAspectJAutoProxy // <aop:aspectj-autoproxy/> //开启AOP注解扫描
@EnableTransactionManagement //<tx:annotation-driven transaction-manager="transactionManager"/>
public class SpringConfig {

    @Bean("threadLocal")
    public ThreadLocal<Connection> createThreadLocal() {
        return new ThreadLocal<>();
    }
}
